﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows.Media.Animation;
using System.Windows;

namespace CommomFunctions
{
    public class Animations
    {
        protected static Grid Gridi = new Grid();
        
        public static void createAnimations(Grid gd)
        {
            Gridi = gd;
        }

        protected void createStoryboard(ThicknessAnimationUsingKeyFrames myThicknessAnimation, object parameter, FrameworkElement obj)
        {
            Storyboard.SetTargetName(myThicknessAnimation, "myAnimatedObject");
            Storyboard.SetTargetProperty(myThicknessAnimation, new PropertyPath(parameter));

            Storyboard ellipseStoryboard = new Storyboard();
            ellipseStoryboard.Children.Add(myThicknessAnimation);

            ellipseStoryboard.FillBehavior = FillBehavior.HoldEnd;
            
            ellipseStoryboard.Begin(obj);
        }

        protected static void createStoryboard(ThicknessAnimationUsingKeyFrames myThicknessAnimation, object parameter, double duration, EventHandler animationCompleted, FrameworkElement obj)
        {
            Storyboard.SetTargetName(myThicknessAnimation, "myAnimatedObject");
            Storyboard.SetTargetProperty(myThicknessAnimation, new PropertyPath(parameter));
            
            Storyboard ellipseStoryboard = new Storyboard();
            ellipseStoryboard.Children.Add(myThicknessAnimation);

            ellipseStoryboard.FillBehavior = FillBehavior.Stop;
            ellipseStoryboard.Duration = TimeSpan.FromSeconds(duration);
            ellipseStoryboard.Completed += new EventHandler(animationCompleted);

            ellipseStoryboard.Begin(obj);
        }
    }
}
